import java.io.*; 

public class XMLComponentsGenerator
{ public static void generateXMLAttribute(String packg, PrintWriter out)
  { if (packg.length() > 0) 
    { out.println("package " + packg + ";\n"); }

    out.println("import java.util.StringTokenizer;"); 
    out.println("import java.util.Vector; ");
    out.println("import java.io.*; ");
    out.println("");
    out.println("public class XMLAttribute");
    out.println("{ String name;");
    out.println("  String value;");
    out.println("");
    out.println("  XMLAttribute()");
    out.println("  { name = \"\"; value = \"\"; }");
    out.println("");
    out.println("  XMLAttribute(String n, String v)");
    out.println("  { name = n; value = v; }");
    out.println("");
    out.println("  public String toString()");
    out.println("  { return name + \"=\" + value; }"); 
    out.println("");
    out.println("  public String getName()");
    out.println("  { return name; } ");
    out.println("");
    out.println("  public String getValue()");
    out.println("  { return value; } ");
    out.println("");
    out.println("  public void setname(String n)");
    out.println("  { name = n; } ");
    out.println("");
    out.println("  public void setvalue(String v)");
    out.println("  { value = v; } ");
    out.println("");
    out.println("  public void getDataDeclaration(PrintWriter out, String instance, String ent)");
    out.println("  { }");

    out.println("  public void getDataDeclarationFromXsi(Vector res, Vector atts, Vector stringatts, Vector oneroles, String instance, String ent)");
    out.println("  { ");
    out.println("    if (stringatts.contains(name))");
    out.println("    { res.add(instance + \".\" + name + \" = \" + value); }"); 
    out.println("    else if (atts.contains(name)) // trim off the quotes");
    out.println("    { String val = value.substring(1,value.length() - 1); ");
    out.println("      res.add(instance + \".\" + name + \" = \" + val); ");
    out.println("    } ");
    out.println("    else // association");
    out.println("    { if (oneroles.contains(name)) ");
    out.println("      { int atind = value.indexOf(\"@\");");
    out.println("       if (atind < 0) ");
    out.println("        { return; } // invalid object value");   
    out.println("        String obj = value.substring(atind + 1, value.length() -1);"); 
    out.println("        int dotind = obj.indexOf(\".\");");
    out.println("        if (dotind < 0) ");
    out.println("        { res.add(instance + \".\" + name + \" = \" + obj + \"0\");");
    out.println("          return; ");
    out.println("        } ");
    out.println("        String obj1 = obj.substring(0,dotind); ");
    out.println("        String obj2 = obj.substring(dotind + 1, obj.length()); ");
    out.println("        res.add(instance + \".\" + name + \" = \" + obj1 + obj2);"); 
    out.println("        return;"); 
    out.println("      } ");
    out.println("      else // a list of objects");
    out.println("      { StringTokenizer st = new StringTokenizer(value,\"\\\" \");"); 
    out.println("        Vector objs = new Vector(); ");
    out.println("        ");
    out.println("        while (st.hasMoreTokens())");
    out.println("        { objs.add(st.nextToken()); }");
    out.println("");
    out.println("        for (int i = 0; i < objs.size(); i++) ");
    out.println("        { String oneobj = (String) objs.get(i);"); 
    out.println("          ");
    out.println("          int atind = oneobj.indexOf(\"@\");");
    out.println("          if (atind < 0) ");
    out.println("          { continue; }   ");
    out.println("          String obj = oneobj.substring(atind + 1, oneobj.length());"); 
    out.println("          int dotind = obj.indexOf(\".\");");
    out.println("          if (dotind < 0) ");
    out.println("          { res.add(obj + \"0 : \" + instance + \".\" + name);");
    out.println("            continue;"); 
    out.println("          } ");
    out.println("          String obj1 = obj.substring(0,dotind); ");
    out.println("          String obj2 = obj.substring(dotind + 1, obj.length()); ");
    out.println("          res.add(obj1 + obj2 + \" : \" + instance + \".\" + name);"); 
    out.println("        }");
    out.println("      } ");
    out.println("    } ");
    out.println("  }");
    out.println("");
    out.println("}"); 
  }
  
  public static void generateXMLNode(String packg, PrintWriter out)
  { if (packg.length() > 0) 
    { out.println("package " + packg + ";\n"); } 

    out.println("import java.util.Vector;");
    out.println("");
    out.println("public class XMLNode");
    out.println("{ String tag;");
    out.println("  Vector attributes = new Vector(); // of XMLAttribute");
    out.println("  Vector subnodes = new Vector(); // of XMLNode");
    out.println("");
    out.println("  XMLNode()");
    out.println("  { tag = \"\"; }");
    out.println("");
    out.println("  XMLNode(String s)");
    out.println("  { tag = s; }");
    out.println("");
    out.println("  public String getTag()");
    out.println("  { return tag; }"); 
    out.println("");
    out.println("  public void settag(String t)");
    out.println("  { tag = t; }"); 
    out.println("");
    out.println("  public void setsubnodes(Vector sn)");
    out.println("  { subnodes = sn; }");
    out.println("");
    out.println("  public Vector getSubnodes()");
    out.println("  { return subnodes; }"); 
    out.println("");
    out.println("  public Vector getAttributes()");
    out.println("  { return attributes; }"); 
    out.println("");
    out.println("  public void setattributes(Vector sn)");
    out.println("  { attributes = sn; }");
    out.println("");
    out.println("  public void addAttribute(XMLAttribute xatt)");
    out.println("  { attributes.add(xatt); }");
    out.println("");
    out.println("  public void addattributes(XMLAttribute xatt)");
    out.println("  { attributes.add(xatt); }");
    out.println("");
    out.println("  public String getAttributeValue(String aname)");
    out.println("  { String res = null; ");
    out.println("    for (int i = 0; i < attributes.size(); i++) ");
    out.println("    { XMLAttribute xatt = (XMLAttribute) attributes.get(i); ");
    out.println("      if (aname.equals(xatt.getName()))");
    out.println("      { res = xatt.getValue();");
    out.println("        break;"); 
    out.println("      } ");
    out.println("    }");
    out.println("    if (res == null) { return res; } ");
    out.println("");
    out.println("    int len = res.length(); ");
    out.println("    if (\"\\\"\".equals(res.charAt(0) + \"\"))");
    out.println("    { res = res.substring(1,len); }"); 
    out.println("    len = res.length();");
    out.println("    if (\"\\\"\".equals(res.charAt(len-1) + \"\"))");
    out.println("    { res = res.substring(0,len-1); }"); 
    out.println("      ");     
    out.println("    return res;"); 
    out.println("  } \n");

    out.println("  public String toString()");
    out.println("  { String res = \"<\" + tag; ");
    out.println("    for (int i = 0; i < attributes.size(); i++) ");
    out.println("    { XMLAttribute xatt = (XMLAttribute) attributes.get(i);"); 
    out.println("      res = res + \" \" + xatt;"); 
    out.println("    } ");
    out.println("    if (subnodes.size() == 0)");
    out.println("    { return res + \"/>\\n\"; }"); 
    out.println("");
    out.println("    res = res + \">\\n\"; ");
    out.println("    for (int j = 0; j < subnodes.size(); j++)"); 
    out.println("    { res = res + subnodes.get(j); } ");
    out.println("    return res + \"</\" + tag + \">\\n\";"); 
    out.println("  } ");
    out.println("}"); 
    out.println(); 
  }
  
  public static void generateXMLParser(String packg, PrintWriter out)
  { if (packg.length() > 0) 
    { out.println("package " + packg + ";\n"); }
 
    out.println("import java.util.Vector; ");
    out.println("import java.util.List; ");
    out.println("import java.io.*;");
    out.println("");
    out.println("public class XMLParser");
    out.println("{ static private final int INUNKNOWN = 0;"); 
    out.println("  static private final int INBASICEXP = 1; ");
    out.println("  static private final int INSYMBOL = 2; ");
    out.println("  static private final int INSTRING = 3; ");
    out.println("");
    out.println("  private Vector lexicals; // of StringBuffer");
    out.println("  private static Vector xmlnodes = new Vector();"); 
    out.println("  private static Vector xmlattributes = new Vector();"); 
    out.println("");
    out.println("");
    out.println("  private boolean isXMLSymbolCharacter(char c)");
    out.println("  { return (c == '<' || c == '>' || c == '=' || c == '*' || c == '/' || c == '\\\\' ||");
    out.println("            c == '-' || c == ',' || c == '\\\'' || c == '?' ||");
    out.println("            c == '+' || c == '&' || c == '^' || c == '|' ||");
    out.println("            c == '(' || c == ')' || c == '{' || c == '}' || c == '[' ||");
    out.println("            c == ']' || c == '#'); ");
    out.println("  } ");
    out.println("");
    out.println("  private boolean isXMLBasicExpCharacter(char c)");
    out.println("  { return (Character.isLetterOrDigit(c) || c == '.' || c == '$' || c == '@' || c == ':'); }"); 
    out.println("");
    out.println("  public static void convertXsiToData(String xmlstring)");
    out.println("  { BufferedWriter brout = null; ");
    out.println("    PrintWriter pwout = null; ");
    out.println("    File outfile = new File(\"./in.txt\");"); 
    out.println("");
    out.println("    try");
    out.println("    { brout = new BufferedWriter(new FileWriter(outfile));"); 
    out.println("      pwout = new PrintWriter(brout); ");
    out.println("    }");
    out.println("    catch (Exception e)");
    out.println("    { System.out.println(\"Errors with file: \" + outfile);");
    out.println("      return; ");
    out.println("    }");
    out.println("");
    out.println("    Vector res = new Vector();");
    out.println("");
    out.println("    XMLParser comp = new XMLParser(); ");
    out.println("    comp.nospacelexicalanalysisxml(xmlstring); ");
    out.println("    XMLNode xml = comp.parseXML(); ");
    out.println("");
    out.println("    java.util.Map instancemap = new java.util.HashMap(); // String --> Vector ");
    out.println("    java.util.Map entmap = new java.util.HashMap();       // String --> String");
    out.println("    Vector entcodes = new Vector();"); 
    out.println("");
    out.println("");
    out.println("    Vector enodes = xml.getSubnodes(); // all instances");
    out.println("    for (int i = 0; i < enodes.size(); i++) ");
    out.println("    { XMLNode enode = (XMLNode) enodes.get(i); ");
    out.println("      String cname = enode.getTag(); ");
    out.println("      Vector einstances = (Vector) instancemap.get(cname);"); 
    out.println("      if (einstances != null) ");
    out.println("      { einstances.add(enode); } "); 
    out.println("    } ");
    out.println("      ");
    out.println("    for (int j = 0; j < entcodes.size(); j++)"); 
    out.println("    { String ename = (String) entcodes.get(j); ");
    out.println("      Vector elems = (Vector) instancemap.get(ename);"); 
    out.println("      for (int k = 0; k < elems.size(); k++) ");
    out.println("      { XMLNode enode = (XMLNode) elems.get(k);");
    out.println("        String tname = enode.getAttributeValue(\"xsi:type\");"); 
    out.println("        if (tname == null) ");
    out.println("        { tname = (String) entmap.get(ename); }"); 
    out.println("        else ");
    out.println("        { int colonind = tname.indexOf(\":\");"); 
    out.println("          if (colonind >= 0)");
    out.println("          { tname = tname.substring(colonind + 1,tname.length()); }");
    out.println("        }   ");
    out.println("        pwout.println(ename + \"\" + k + \" : \" + tname);"); 
    out.println("      } ");
    out.println("    } ");
    out.println("");
    out.println("    for (int j = 0; j < entcodes.size(); j++) ");
    out.println("    { String ename = (String) entcodes.get(j); ");
    out.println("      Vector elems = (Vector) instancemap.get(ename); ");
    out.println("      for (int k = 0; k < elems.size(); k++) ");
    out.println("      { XMLNode enode = (XMLNode) elems.get(k);");
    out.println("        Vector atts = enode.getAttributes();");
    out.println("        for (int p = 0; p < atts.size(); p++) ");
    out.println("        { XMLAttribute patt = (XMLAttribute) atts.get(p);"); 
    out.println("          if (patt.getName().equals(\"xsi:type\") || patt.getName().equals(\"xmi:id\")) { }"); 
    out.println("          else ");
    out.println("          { patt.getDataDeclaration(pwout,ename + k, (String) entmap.get(ename)); }"); 
    out.println("        } ");
    out.println("      }  ");
    out.println("    } ");
    out.println("    try { pwout.close(); } catch (Exception ee) { }"); 
    out.println("  }");
    out.println("");
    out.println("");
    out.println("  public void nospacelexicalanalysisxml(String str)"); 
    out.println("  { int in = INUNKNOWN; ");
    out.println("    char previous = ' '; ");
    out.println("");
    out.println("    int explen = str.length();"); 
    out.println("    lexicals = new Vector(explen);  /* Sequence of lexicals */ ");
    out.println("    StringBuffer sb = null;    /* Holds current lexical item */ ");
    out.println("");
    out.println("    for (int i = 0; i < explen; i++)");
    out.println("    { char c = str.charAt(i); ");
    out.println("      if (in == INUNKNOWN) ");
    out.println("      { if (isXMLSymbolCharacter(c))");
    out.println("        { sb = new StringBuffer();     // start new buffer for the symbol");
    out.println("          lexicals.addElement(sb);  ");
    out.println("          in = INSYMBOL; ");
    out.println("          sb.append(c); ");
    out.println("          previous = c; ");
    out.println("        }");
    out.println("        else if (isXMLBasicExpCharacter(c))");
    out.println("        { sb = new StringBuffer();     // start new buffer for the expression");
    out.println("          lexicals.addElement(sb);  ");
    out.println("          in = INBASICEXP; ");
    out.println("          sb.append(c); ");
    out.println("        }           ");
    out.println("        else if (c == '\"')");
    out.println("        { sb = new StringBuffer();     // start new buffer for the string");
    out.println("          lexicals.addElement(sb);  ");
    out.println("          in = INSTRING; ");
    out.println("          sb.append(c); ");
    out.println("        }");
    out.println("        else if (c == ' ' || c == '\\n' || c == '\\t')"); 
    out.println("        { } ");
    out.println("        else");
    out.println("        { sb = new StringBuffer();     // unrecognised lexical");
    out.println("          lexicals.addElement(sb);  ");
    out.println("          sb.append(c); ");
    out.println("        }");
    out.println("      } ");
    out.println("      else if (in == INBASICEXP)");
    out.println("      { if (isXMLBasicExpCharacter(c) || c == '\"')");
    out.println("        { sb.append(c); }              // carry on adding to current basic exp");
    out.println("        else if (isXMLSymbolCharacter(c))");
    out.println("        { sb = new StringBuffer();     // start new buffer for the symbol");
    out.println("          lexicals.addElement(sb);  ");
    out.println("          in = INSYMBOL; ");
    out.println("          sb.append(c); ");
    out.println("          previous = c; ");
    out.println("        }");
    out.println("        else if (c == ' ' || c == '\\n' || c == '\\t')");
    out.println("        { in = INUNKNOWN; } ");
    out.println("        else");
    out.println("        { sb = new StringBuffer();     // unrecognised lexical");
    out.println("          lexicals.addElement(sb);  ");
    out.println("          in = INUNKNOWN; ");
    out.println("          sb.append(c); ");
    out.println("        }");
    out.println("      }");
    out.println("      else if (in == INSYMBOL)");
    out.println("      { if (c == '\"')");
    out.println("        { sb = new StringBuffer();     // start new buffer for the string");
    out.println("          lexicals.addElement(sb);  ");
    out.println("          in = INSTRING; ");
    out.println("          sb.append(c); ");
    out.println("        }");
    out.println("        else if (c == '(' || c == ')')");
    out.println("        { sb = new StringBuffer();     // start new buffer for the new symbol");
    out.println("          lexicals.addElement(sb);  ");
    out.println("          in = INSYMBOL; ");
    out.println("          previous = c; ");
    out.println("          sb.append(c); ");
    out.println("        }");
    out.println("        else if (isXMLBasicExpCharacter(c))");
    out.println("        { sb = new StringBuffer();     // start new buffer for basic exp");
    out.println("          lexicals.addElement(sb);  ");
    out.println("          in = INBASICEXP; ");
    out.println("          sb.append(c); ");
    out.println("        }");
    out.println("        else if (isXMLSymbolCharacter(c))");
    out.println("        { if (validFollowingCharacter(previous,c))");
    out.println("          { sb.append(c); } ");
    out.println("          else ");
    out.println("          { sb = new StringBuffer();     // start new buffer for the new symbol");
    out.println("            lexicals.addElement(sb);  ");
    out.println("            in = INSYMBOL; ");
    out.println("            sb.append(c); ");
    out.println("          }");
    out.println("          previous = c;"); 
    out.println("        } ");
    out.println("        else if (c == ' ' || c == '\\n' || c == '\\t')");
    out.println("        { in = INUNKNOWN; } ");
    out.println("      }");
    out.println("      else if (in == INSTRING)"); 
    out.println("      { if (c == '\"')  /* end of string */"); 
    out.println("        { sb.append(c);"); 
    out.println("          in = INUNKNOWN; ");
    out.println("        } ");
    out.println("        else ");
    out.println("        { sb.append(c); }"); 
    out.println("      }    ");
    out.println("      previous = c;"); 
    out.println("    }");
    out.println("  }");
    out.println("");
    out.println("  private boolean validFollowingCharacter(char c1, char c2)");
    out.println("  { if (c1 == '<') ");
    out.println("    { if (c2 == '=' || c2 == ':' || c2 == '/') { return true; }"); 
    out.println("      return false; ");
    out.println("    }");
    out.println("    if (c1 == '>')");
    out.println("    { if (c2 == '=') { return true; }"); 
    out.println("      return false; ");
    out.println("    }");
    out.println("    if (c1 == '/') ");
    out.println("    { if (c2 == '=' || c2 == ':' || c2 == '\\\\' || c2 == '>') { return true; }"); 
    out.println("      return false; ");
    out.println("    }");
    out.println("    if (c1 == '\\\\')");
    out.println("    { if (c2 == '/') { return true; } ");
    out.println("      return false; ");
    out.println("    }");
    out.println("    if (c1 == '=')");
    out.println("    { if (c2 == '>') { return true; } ");
    out.println("      return false; ");
    out.println("    }");
    out.println("    if (c1 == '-')");
    out.println("    { if (c2 == '>') { return true; }"); 
    out.println("      return false; ");
    out.println("    }");
    out.println("    if (c1 == ':')");
    out.println("    { if (c2 == '=') { return true; }"); 
    out.println("      return false; ");
    out.println("    }");
    out.println("    return false;"); 
    out.println("  } ");
    out.println("");
    out.println("");
    out.println("  public XMLNode parseXML()");
    out.println("  { for (int i = 0; i < lexicals.size(); i++) ");
    out.println("    { if (\"?\".equals(lexicals.get(i) + \"\") &&"); 
    out.println("          \">\".equals(lexicals.get(i+1) + \"\"))");
    out.println("      { return parsexmlnode(i+2,lexicals.size() - 1); }"); 
    out.println("    } ");
    out.println("    return null;"); 
    out.println("  } ");
    out.println("");
    out.println("  public XMLNode parsexmlnode(int st, int en)");
    out.println("  { if (\"<\".equals(lexicals.get(st) + \"\"))");
    out.println("    { String tag = lexicals.get(st + 1) + \"\";");
    out.println("");
    out.println("      XMLNode xnode = new XMLNode();");
    out.println("      xnode.settag(tag); ");
    out.println("      xmlnodes.add(xnode); ");
    out.println("");
    out.println("      for (int i = st + 2; i <= en; i++)");
    out.println("      { String str = lexicals.get(i) + \"\";");
    out.println("        if (i + 1 <= en)");
    out.println("        { if (\"=\".equals(lexicals.get(i+1) + \"\"))");
    out.println("          { XMLAttribute xatt = new XMLAttribute(); ");
    out.println("            xatt.setname(str);");
    out.println("            xatt.setvalue(lexicals.get(i+2) + \"\");");
    out.println("            xnode.addattributes(xatt);");
    out.println("            xmlattributes.add(xatt); ");
    out.println("          }");
    out.println("          else if (\"</\".equals(str) && i + 2 <= en &&"); 
    out.println("              tag.equals(lexicals.get(i+1) + \"\") &&");
    out.println("              \">\".equals(lexicals.get(i+2) + \"\"))");
    out.println("          { return xnode; }");
    out.println("        }");
    out.println("");
    out.println("        if (\">\".equals(str))");
    out.println("        { Vector sns = parsesubnodes(tag, i+1, en);");
    out.println("          xnode.setsubnodes(sns);");
    out.println("          return xnode;");
    out.println("        }");
    out.println("");
    out.println("        if (\"/>\".equals(str))");
    out.println("        { return xnode; }");
    out.println("      }");
    out.println("    }");
    out.println("    return null;");
    out.println("  }");
    out.println("");
    out.println("  public Vector parsesubnodes(String tag, int st, int en)");
    out.println("  { Vector res = new Vector();");
    out.println("    for (int i = st; i <= en; i++)");
    out.println("    { String str = lexicals.get(i) + \"\";");
    out.println("      if (\"</\".equals(str) && i + 2 <= en &&");
    out.println("           tag.equals(lexicals.get(i+1) + \"\") &&");
    out.println("           \">\".equals(lexicals.get(i+2) + \"\"))");
    out.println("      { return res; }");
    out.println("");
    out.println("      if (\">\".equals(str)) ");
    out.println("      { String tag1 = lexicals.get(st + 1) + \"\"; ");
    out.println("        for (int j = i+1; j < en; j++) ");
    out.println("        { String str1 = lexicals.get(j) + \"\"; ");
    out.println("          if (\"</\".equals(str1) && tag1.equals(lexicals.get(j+1) + \"\"))");
    out.println("          { XMLNode xn = parsexmlnode(st,j+2); ");
    out.println("            if (xn != null) { res.add(xn); } ");
    out.println("            res.addAll(parsesubnodes(tag,j+3,en));");
    out.println("            return res;");
    out.println("          } ");
    out.println("        }");
    out.println("      }");  
    out.println("");
    out.println("      if (\"</\".equals(str) && i + 2 <= en &&");
    out.println("           !(tag.equals(lexicals.get(i+1) + \"\")) &&");
    out.println("           \">\".equals(lexicals.get(i+2) + \"\"))");
    out.println("      { XMLNode xn = parsexmlnode(st,i+2);");
    out.println("        if (xn != null) { res.add(xn); }");
    out.println("        res.addAll(parsesubnodes(tag,i+3,en));");
    out.println("        return res;");
    out.println("      }");
    out.println("");
    out.println("      if (\"/>\".equals(str))");
    out.println("      { XMLNode xn = parsexmlnode(st,i);");
    out.println("");
    out.println("        if (xn != null) { res.add(xn); }");
    out.println("        res.addAll(parsesubnodes(tag,i+1,en));");
    out.println("        return res;");
    out.println("      }");
    out.println("    }");
    out.println("    return res;");
    out.println("  }"); 
    out.println("");
    out.println("  public static XMLNode parseXML(String f)");
    out.println("  { BufferedReader br = null;");
    out.println("    String s;");
    out.println("    boolean eof = false;");
    out.println("    File file = new File(f);");  
    out.println("");
    out.println("    try");
    out.println("    { br = new BufferedReader(new FileReader(file)); }");
    out.println("    catch (FileNotFoundException e)");
    out.println("    { System.out.println(\"File not found: \" + file);");
    out.println("      return null;"); 
    out.println("    }");
    out.println("    String xmlstring = \"\"; ");
    out.println("");
    out.println("    while (!eof)");
    out.println("    { try { s = br.readLine(); }");
    out.println("      catch (IOException e)");
    out.println("      { System.out.println(\"Reading file failed.\");");
    out.println("        return null;"); 
    out.println("      }");
    out.println("      if (s == null) ");
    out.println("      { eof = true;"); 
    out.println("        break;"); 
    out.println("      }");
    out.println("      else ");
    out.println("      { xmlstring = xmlstring + s + \" \"; }"); 
    out.println("    }");
    out.println("");
    out.println("    xmlnodes.clear(); ");
    out.println("    xmlattributes.clear();"); 
    out.println("");
    out.println("    XMLParser comp = new XMLParser();  ");
    out.println("    comp.nospacelexicalanalysisxml(xmlstring);"); 
    out.println("    XMLNode xml = comp.parseXML();"); 
    out.println("");
    out.println("    try { br.close(); } catch(IOException e) { return null; }");
    out.println("    return xml;"); 
    out.println("  }"); 
    out.println("");
    out.println("  public static List allXMLNodes()");
    out.println("  { return xmlnodes; }"); 
    out.println("");
    out.println("  public static List allXMLAttributes()");
    out.println("  { return xmlattributes; }"); 
    out.println("");
    out.println("  public static void convertXsi()");
    out.println("  { BufferedReader br = null;");
    out.println("    ");
    out.println("    Vector res = new Vector();");
    out.println("    String s;");
    out.println("    boolean eof = false;");
    out.println("    File infile = new File(\"./xsi.txt\");  /* default */");     
    out.println("    try");
    out.println("    { br = new BufferedReader(new FileReader(infile)); }");
    out.println("    catch (Exception e)");
    out.println("    { System.out.println(\"Errors with files: \" + infile);");
    out.println("      return;"); 
    out.println("    }");
    out.println("    String xmlstring = \"\";"); 
    out.println("");
    out.println("    while (!eof)");
    out.println("    { try { s = br.readLine(); }");
    out.println("      catch (IOException e)");
    out.println("      { System.out.println(\"Reading failed.\");");
    out.println("        return;"); 
    out.println("      }");
    out.println("      if (s == null) ");
    out.println("      { eof = true;"); 
    out.println("        break;"); 
    out.println("      }");
    out.println("      else ");
    out.println("      { xmlstring = xmlstring + s + \" \"; }"); 
    out.println("    }");
    out.println("");
    out.println("    XMLParser.convertXsiToData(xmlstring);");
    out.println("  }"); 
    out.println("");
    out.println("  public static String saveXSI(Vector v1, Vector v2)");
    out.println("  { StringBuffer out = new StringBuffer(); ");
    out.println("    return out.toString();"); 
    out.println("  }");
    out.println("");
    out.println("}"); 
  }
}
